package com.bnz.bnzshop.controller;

import com.bnz.bnzshop.vo.ConnectionVo;
import com.bnz.common.utils.PageUtils;
import com.bnz.bnzshop.entity.TypeTemplateEntity;
import com.bnz.bnzshop.service.TypeTemplateService;
import com.bnz.pojo.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.List;
import java.util.Map;


/**
 * 
 *
 * @author baizhi
 * @email 315104869@qq.com
 * @date 2022-10-30 15:21:50
 */
@RestController
@RequestMapping("shop/typetemplate")
public class TypeTemplateController {
    @Autowired
    private TypeTemplateService typeTemplateService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    //@RequiresPermissions("manager:typetemplate:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = typeTemplateService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
        public R info(@PathVariable("id") String id){
		TypeTemplateEntity typeTemplate = typeTemplateService.getById(id);

        return R.ok().put("typeTemplate", typeTemplate);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
        public R save(@RequestBody TypeTemplateEntity typeTemplate){
		typeTemplateService.save(typeTemplate);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
        public R update(@RequestBody TypeTemplateEntity typeTemplate){
		typeTemplateService.updateById(typeTemplate);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
        public R delete(@RequestBody String[] ids){
		    typeTemplateService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }
    @RequestMapping("/template/{id}")
        public R template(@PathVariable Integer id){
        List<ConnectionVo>  querytemplate = typeTemplateService.querytemplate(id);
        return R.ok().put("template",querytemplate);
    }
}
